<?php
if( isset($_GET['themeurl']) ) {
    $shkid_url = $_GET['themeurl'] . '/plugins/shortcodekid/css';
}else {
    $shkid_url = '../../css';
}

if( isset($_GET['mceurl']) ) {
    $mce_url = $_GET['mceurl'];
}else {
    $mce_url = '../../../../../../../wp-includes/js/tinymce';
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>Image Slider</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	
    <script language="javascript" type="text/javascript" src="<?php echo $mce_url; ?>/tiny_mce_popup.js"></script>
	<script language="javascript" type="text/javascript" src="<?php echo $mce_url; ?>/utils/mctabs.js"></script>
	<script language="javascript" type="text/javascript" src="<?php echo $mce_url; ?>/utils/form_utils.js"></script>
	<script language="javascript" type="text/javascript" src="<?php echo $mce_url; ?>/../jquery/jquery.js"></script>
    <link rel="stylesheet" type="text/css" href="<?php echo $shkid_url; ?>/window.css">
	
    <script language="javascript" type="text/javascript">
	function init() {
		
		tinyMCEPopup.resizeToInnerSize();
		
	}
	
	function insertShortcode() {
		
		var tagtext;
		var selectedContent = tinyMCE.activeEditor.selection.getContent();
		var lists_bt = document.getElementById('lists_panel');
		
		// who is active ?
		if (lists_bt.className.indexOf('current') != -1) {
			
			var slider_height = document.getElementById('slider_height').value;
			var slider_size = jQuery('#slider_size > input[type=radio]:checked').val();
            var slider_title = jQuery('#slider_title').val();
            
			if(selectedContent != '') {
				
				tagtext = '[image_slider size="' + slider_size + '"] [slide size="' + slider_size + '" height="'+slider_height+'" title="' + slider_title + '"]' + selectedContent + '[/slide] [/image_slider] ';
				
			} else {
				
				tagtext = '[image_slider size="' + slider_size + '"] [slide size="' + slider_size + '" height="'+slider_height+'" title="' + slider_title + '"] Your_Image_URL_Here [/slide] [/image_slider] ';
				
			}
				
		}
	
		
		if(window.tinyMCE) {
			window.tinyMCE.execInstanceCommand('content', 'mceInsertContent', false, tagtext);
			//Peforms a clean up of the current editor HTML. 
			//tinyMCEPopup.editor.execCommand('mceCleanup');
			//Repaints the editor. Sometimes the browser has graphic glitches. 
			tinyMCEPopup.editor.execCommand('mceRepaint');
			tinyMCEPopup.close();
		}
		
		return;
	}
	</script>
	<base target="_self" />
    
	<style type="text/css">
	
    label span { color: #f00; }
	
    </style>
    
</head>
<body onload="init();">
<!-- <form onsubmit="insertLink();return false;" action="#"> -->
	<form name="SKShortcodes" action="#">
	<div class="tabs">
		<ul>
			<li id="lists_tab" class="current"><span><a href="javascript:mcTabs.displayTab('lists_tab','lists_panel');" onmousedown="return false;">Image Slider</a></span></li>
		</ul>
	</div>
	
	<div class="panel_wrapper">
    
		<!-- small panel -->
		<div id="lists_panel" class="panel current">
        
        <fieldset>
        
            <legend>Options:</legend>

            <p id="slider_size">

                <label for="slider_size">Width:</label>

                <input id="slider_size_half" name="slider_size" type="radio" value="half" checked="checked"/>
                <label for="slider_size_half">Half</label> &nbsp;&nbsp;
                        
                <input id="slider_size_full" name="slider_size" type="radio" value="full"/>
                <label for="slider_size_full">Full</label>                   
                        
            </p>
            
            <label for="slider_width">Height:</label> <input type="text" name="slider_width" id="slider_height" style="width: 210px" /> px
                        
            <em>Insert the height of your slider images.</em>
        
        </fieldset>
        
        <fieldset>
        
            <legend>Slider Image title:</legend>
            
            <textarea name="slider_title" id="slider_title" class="wide-field"></textarea>
            
            <em>An example will be inserted in your text editor. To have multiple just wrap each image URL in [slide] ... [/slide] tags.</em>
        
        </fieldset>
		</div>
		<!-- end small panel -->
		
	</div>

	<div class="mceActionPanel">
		<div style="float: left">
			<input type="button" id="cancel" name="cancel" value="Close" onclick="tinyMCEPopup.close();" />
		</div>

		<div style="float: right">
			<input type="submit" id="insert" name="insert" value="Insert" onclick="insertShortcode();" />
		</div>
	</div>
</form>
</body>
</html>
<?php

?>
